<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head>
<meta charset="UTF-8">
<title>新建简历</title>
<script type="text/javascript" src="../jquery/jquery-3.5.1.js"></script>
<link href="../bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet" type="text/css"> 
<script src="../bootstrap-3.3.7-dist/js/bootstrap.js"></script>
</head>
<body >
<nav class="navbar navbar-default">
<div class="row">
  <div class="col-xs-12 col-md-8 col-md-offset-1">
  <div class="col-md-1">
  </div>
   <h1 >我的简历</h1>
   </div>
    
  <div class="col-xs-6 col-md-4"> 

  </div>
</div>
</nav>
<div class="row">
  <div class="col-md-2">
   <div style="display:none">
   <h5 sec:authentication="principal.uid" id="id" name="id"></h5>
   </div> 
   <button id="CreatNewResumebtn" class="btn btn-primary btn-lg btn-block">新建简历</button>
   <button id="MyResumeBtn" class="btn btn-primary btn-lg btn-block">我的简历</button>
     <button id="MyHistoryResumeBtn" class="btn btn-primary btn-lg btn-block">投递记录</button>
  </div>
  <div class="col-md-8" >
   <!-- 粘贴招聘信息 -->
  <table  class="table table-hover">
  <tbody id="resume_tbody">
  <!-- 粘贴分页信息 -->
  </tbody>
</table>
 <div class="col-md-4 col-md-offset-4" id="resume_info">
 <!-- 粘贴分页标签向导 -->
</div>
  </div>
  <div class="col-md-2"></div>
</div>
<!-- 模态框--新建简历 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">新建简历</h4>
      </div>
      <div class="modal-body">
      <div class="row">
  <div class="col-md-6 col-md-offset-3 ">
<form id="Resume" class="form-horizontal">
 <div class="form-group" style="display:none">
    <input  type="text" class="form-control" id="uid" name="uid">
  </div>
  <div class="form-group ">
    <label >姓名</label>
    <input type="text" class="form-control " id="name" name="name" placeholder="姓名">
  </div>
  <div class="form-group ">
    <label >身份证</label>
    <input type="text" class="form-control " id="identity" name="identity" placeholder="身份证">
  </div>
  <div class="form-group ">
    <label >年龄</label>
    <input type="text" class="form-control " id="age" name="age" placeholder="年龄">
  </div >
  <div class="form-group ">
    <label >学历</label>
    <input type="text" class="form-control " id="xueli" name="xueli" placeholder="学历">
  </div >
  <div class="form-group ">
    <label >毕业院校</label>
    <input type="text" class="form-control " id="college" name="college" placeholder="毕业院校">
  </div >
  <div class="form-group ">
    <label >专业</label>
    <input type="text" class="form-control " id="major" name="major" placeholder="专业">
  </div >
  <div class="form-group ">
    <label >联系电话</label>
    <input type="text" class="form-control " id="phone" name="phone" placeholder="联系电话">
  </div >
  <div class="form-group ">
    <label >邮箱</label>
    <input type="text" class="form-control " id="email" name="email" placeholder="邮箱">
  </div >
  <div class="form-group ">
    <label >意向岗位</label>
    <input type="text" class="form-control " id="zhiwei" name="zhiwei" placeholder="意向岗位">
  </div >
  <div class="form-group ">
    <label >期望薪资</label>
    <input type="text" class="form-control " id="intendedsalary" name="intendedsalary" placeholder="期望薪资">
  </div >
  <div class="form-group ">
    <label >工作经验</label>
    <input type="text" class="form-control " id="workexperience" name="workexperience" placeholder="工作经验">
  </div >
  <div class="form-group ">
    <label >专业技能</label>
    <input type="text" class="form-control " id="skills" name="skills" placeholder="专业技能">
  </div > 
</form>
</div>
</div>
    </div><!-- model_body -->

      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
        
        <button type="button" class="btn btn-primary" id ="save">保存</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->


<!-- 模态框,显示详细简历信息 -->
<div id="myResumeModal" class="modal fade" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4  id="zpzt"class="modal-title"></h4>
      </div>
      <div id="oneresume" class="modal-body">
        <!-- <p>One fine body&hellip;</p> -->
        <!-- 此处放消息体 -->
      </div>
      <div class="modal-footer">
       
        <button id="gbbtn" type="button" class="btn btn-primary">关闭</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

<!-- 查看我投递的简历详细信息模态框 -->
<div id="sweekerResumeModal" class="modal fade" tabindex="-1" role="dialog">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4  id="applytitle"class="modal-title"></h4>
      </div>
      <div id="sweekerresume" class="modal-body">
        <!-- <p>One fine body&hellip;</p> -->
        <!-- 此处放消息体 -->
      </div>
      <div class="modal-footer">
       
        <button id="sweekerResumeModalbtn" type="button" class="btn btn-primary">关闭</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<script type="text/javascript">
//全局变量，用户id
var uid;
$(function(){
	 uid=$("#id").text();
	$("#uid").attr("value",uid);
}); 

//新建简历按钮
$("#CreatNewResumebtn").click(function(){
	$("#resume").empty();
	$("#myModal").modal({
		backdrop:"static"
	});
	})

//手动关闭简历模态框
$("#gbbtn").click(function(){
	$("#myResumeModal").modal('hide');
})
//手动关闭简历投递模态框
$("#sweekerResumeModalbtn").click(function(){
   $("#sweekerResumeModal").modal('hide');	
})
//新建简历
$("#save").click(function () {
	
	$.ajax({
		url:"/user/insertresume",
		type:"POST",
		data:$("#Resume").serialize(),
		success:function(result) {
			alert(result.msg);
		}
	});
	
}); 


//查询我的历史投递记录
$("#MyHistoryResumeBtn").click(function(){
 
	$.ajax({
		url:"/user/selectResumeWithRecruitmentByTUid",
		type:"POST",
		data:{uid:uid,pages:1},
		ansyc:false,
		success:function(result){
			if(result.code==200){
				alert("还没有投递记录，赶紧投递您心仪的工作吧");
			}else if(result.code==100){
				PasteResumeInfoWtihRecruitment(result);
				//记录数大于5才进行粘贴
				pasteResumeWithRecruitmentNavigatepageNums(result);
		}
		}
	});
	
})


//分页粘贴投递信息
function PasteResumeInfoWtihRecruitment(result){
	var ResumeInfos=result.extend.selectResumeWithRecruitmentByTUid.list;
	
	$("#resume_tbody").empty();
	$.each(ResumeInfos,function(index,items){
		
 		////列表第一列
		var zpn=$("<span></span>").append(items.recruitmentInfo.zpname).addClass("label label-info");
		var zapname=$("<dt></dt>").append(zpn);
		var company=$("<dt></dt>").append(items.recruitmentInfo.companyInfo.company);
		var dl1=$("<dl></dl>").append(zapname);
		var td1=$("<td></td>").append(dl1);
		
 		var tdname=$("<dt></dt>").append(items.name);
	    var college=$("<dt></dt>").append(items.college);
	    var dl2=$("<dl></dl>").append(tdname).append(college);
		var td2=$("<td></td>").append(dl2);
		
	    var detialbtn=$("<button></button>").append("详情").addClass("btn btn-primary");
	    
	    var sweekerresume=items;
	    detialbtn.click(function(){
	    	 SweekerResumeDetialInfo(sweekerresume);
	    });
	    
	    var date=$("<span></span>").append(items.jltdInfo.time);
		var datemodel=$("<span></span>").addClass("glyphicon glyphicon-time");
		var btndt=$("<dt></dt>").append(detialbtn);
		var datadt=$("<dt></dt>").append(datemodel).append(date);
		var dl3=$("<dl></dl>").append(btndt).append(datadt);
		var td3=$("<td></td>").append(dl3);
		
		var ifChecked=items.jltdInfo.checked;
		var dl4=$("<dl></dl>");
		if(ifChecked==false){
			var ifRead=$("<span></span>").append("未审阅");
			var dt1=$("<dt></dt>").append(ifRead);
			dl4.append(dt1);
		}else if(ifChecked==true){
			var ifRead=$("<span></span>").append("已审阅");
			var dt2=$("<dt></dt>").append(ifRead);
			dl4.append(dt2);
		}
		
		var td4=$("<td></td>").append(dl4);
		 $("<tr></tr>")
	        .append(td1)
	        .append(td2)
	        .append(td3)
	        .append(td4)
	        .appendTo("#resume_tbody");
			
	});
}
//粘贴投递记录导航信息
function pasteResumeWithRecruitmentNavigatepageNums(result) {
	
	//插入前先清空
	$("#resume_info").empty();
	var navigatepages=result.extend.selectResumeWithRecruitmentByTUid.navigatepageNums;
	//当前页
	var pageNum=result.extend.selectResumeWithRecruitmentByTUid.pageNum;
	
	
	var firstPage=$("<li></li>").append($("<a></a>").append("首页"));
	
	firstPage.click(function () {
		resumeWithRecruitmentToPage(1);
	});
	var perviousPage=$("<li></li>").append($("<a></a>").append("&laquo;"));
	
	perviousPage.click(function() {
			if(result.extend.selectResumeWithRecruitmentByTUid.hasPreviousPage==true){
			
				resumeWithRecruitmentToPage(result.extend.selectResumeWithRecruitmentByTUid.prePage);
			}
		});
		
	var nextPage=$("<li></li>").append($("<a></a>").append("&raquo;"));
	
	nextPage.click(function() {
	if(result.extend.selectResumeWithRecruitmentByTUid.hasNextPage==true)
	{
		
		resumeWithRecruitmentToPage(result.extend.selectResumeWithRecruitmentByTUid.nextPage);
	}
	});
	var lastPage=$("<li></li>").append($("<a></a>").append("末页"));
	
	lastPage.click(function () {
		resumeWithRecruitmentToPage(result.extend.selectResumeWithRecruitmentByTUid.pages);
	});
	
	var ul=$("<ul></ul>").addClass("pagination");
	var nav=$("<nav></nav>");
	//判断是否有前一页
	if(result.extend.selectResumeWithRecruitmentByTUid.hasPreviousPage==false)
		{
		firstPage.addClass("disabled");
		perviousPage.addClass("disabled ");
		}
	ul.append(firstPage).append(perviousPage);
	//遍历插入并添加点击事件
	$.each(navigatepages,function(index,items){
		var numli= $("<li></li>").append($("<a></a>").append(items));
		if(pageNum==items){
		
			numli.addClass("active");
		}
		numli.click(function() {
			resumeWithRecruitmentToPage(items);
		});
		ul.append(numli);
		});
	
	//判断是否有后一页
	if(result.extend.selectResumeWithRecruitmentByTUid.hasNextPage==false)
	{
	nextPage.addClass("disabled");
	lastPage.addClass("disabled");
	}
	ul.append(nextPage).append(lastPage);
	nav.append(ul).appendTo("#resume_info");
}

//投递分页标签点击进行分页跳转
function resumeWithRecruitmentToPage(page) {	
	$.ajax({
		url:"/user/selectResumeWithRecruitmentByTUid",
		type:"POST",
		data:{uid:uid,pages:page},
		ansyc:false,
		success:function(result){
			PasteResumeInfoWtihRecruitment(result);	
			pasteResumeWithRecruitmentNavigatepageNums(result);

		}
	});
}


//点击我的简历查看简历信息
$("#MyResumeBtn").click(function () {
	$("#resume_info").empty();
	SearchResumeInfo();
	
}); 
//查询简历信息
function SearchResumeInfo(){
	//粘贴前先清空
	//$("#resume_tbody").empty();
	$.ajax({
		url:"/user/selectResumeByUid",
		type:"POST",
		data:{uid:uid , pages: 1},
		async: false,  
		success:function(result) {
			if(result.code==100){
				//粘贴简历分页信息
				 MyResumeInfoPaste(result);
					//粘贴简历分页导航信息
				pasteResumeNavigatepageNums(result);
				
			}else if(result.code==200){
				alert(result.code);
				alert("您还没有填写简历");
			}
			
		}
	});
}

//显示我的单个投递信息的详情

function SweekerResumeDetialInfo(sweekerresume){
	$("#sweekerresume").empty();
	$("#applytitle").empty();
	$("#sweekerResumeModal").modal({
		backdrop:"static"
	});
	$("#applytitle").append("应聘岗位： "+sweekerresume.recruitmentInfo.zpname);
	var baseinfo=$("<span></span>").append("基本信息").addClass("label label-info");
	var baseinfo1=$("<dt></dt>").append(baseinfo);
	var baseinfo2=$("<dt></dt>")
	.append("姓名： ").append(sweekerresume.name)
	.append("  ,  ")
	.append("年龄：").append(sweekerresume.age)
	.append("  ,  ");
	var baseinfo3=$("<dt></dt>")
	.append("邮箱：").append(sweekerresume.email)
	.append(" , ")
	.append("电话：").append(sweekerresume.phone);
	//
	var educationinfo=$("<span></span>").append("教育背景").addClass("label label-info");
	var baseinfo4=$("<dt></dt>").append(educationinfo);

	var baseinfo5=$("<dt></dt>")
	.append("院校： ").append(sweekerresume.college)
	.append("  ,  ")
	.append("专业：").append(sweekerresume.major);
	//
	var applyinfo=$("<span></span>").append("求职意向").addClass("label label-info");
	var baseinfo6=$("<dt></dt>").append(applyinfo);

	var baseinfo7=$("<dt></dt>")
	.append("意向行业： ").append(sweekerresume.zhiwei)
	.append("  ,  ")
	.append("意向薪资：").append(sweekerresume.intendedsalary)
	.append("  ,  ")
	.append("工作经历：").append(sweekerresume.workexperience)
	.append("  ,  ")
	.append("专业技能：").append(sweekerresume.skills);
	$("<dl></dl>")
	.append(baseinfo1)
	.append(baseinfo2)
	.append(baseinfo3)
	.append(baseinfo4)
	.append(baseinfo5)
	.append(baseinfo6)
	.append(baseinfo7)
	.appendTo("#sweekerresume");
}


//分页粘贴我的简历信息
function MyResumeInfoPaste(result){
	$("#resume_tbody").empty();
	var ResumeInfos=result.extend.resumepageInfos.list;
	$.each(ResumeInfos,function(index,items){
	////列表第一列
		
		var name=$("<dt></dt>").append(items.name);
		var xueli=$("<dt></dt>").append(items.xueli);
		var dl1=$("<dl></dl>").append(name).append(xueli);
		var td1=$("<td></td>").append(dl1);
		
 		var college=$("<dt></dt>").append(items.college);
	    var major=$("<dt></dt>").append(items.major);
	    var dl2=$("<dl></dl>").append(college).append(major);
		var td2=$("<td></td>").append(dl2);
		
		var zhiwei=$("<dt></dt>").append(items.zhiwei);
	    var skills=$("<dt></dt>").append(items.skills);
	    var dl3=$("<dl></dl>").append(zhiwei).append(skills);
		var td3=$("<td></td>").append(dl3);
		
	    var detialbtn=$("<button></button>").append("详情").addClass("btn btn-primary");
	    var jlid=items.jlid;
	    //添加点击事件,查看简历详情
	    detialbtn.click(function(){
	    	$.ajax({
	    		url:"/user/selectOneResumeWithRecruitemntByJlid",
	    		type:"POST",
	    		data:{jlid:jlid},
	    		ansyc:false,
	    		success:function(result){
	    			if(result.code==100){
	    				MyResumeDetialInfo(result);
	    			}else if(result.code==200){
	    				alert("查询出错");
	    			}
	    		}
	    	});
	    });
	    
		var btndt=$("<dt></dt>").append(detialbtn);
		
		var deletebtn=$("<button></button>").append("删除").addClass("btn btn-danger");
		//添加点击事件,删除简历
		deletebtn.click(function(){
			$.ajax({
				url:"/user/deleteResumeByPrimaryKey",
				type:"POST",
				data:{jlid:jlid},
				async:false,
				success:function(result){
					if(result.code==100){
						alert("删除成功");
						SearchResumeInfo();
					}else if(result.code==200){
						alert("删除失败");
					}
				}
			});
		});
		var btndel=$("<dt></dt>").append(deletebtn);
		var dl4=$("<dl></dl>").append(btndt).append(btndel);
		var td4=$("<td></td>").append(dl4);
	    
		 $("<tr></tr>")
	        .append(td1)
	        .append(td2)
	        .append(td3)
	        .append(td4)
	        .appendTo("#resume_tbody");
		
	});
}

//简历分页标签点击进行跳转
function MyResumeTopage(page) {	
	$.ajax({
		url:"/user/selectResumeByUid",
		type:"POST",
		data:{uid:uid,pages:page},
		ansyc:false,
		success:function(result){
			pasteResumeNavigatepageNums(result);
			MyResumeInfoPaste(result);
		}
	});
}
//粘贴简历分页导航信息
function pasteResumeNavigatepageNums(result) {
	
	//插入前先清空
	$("#resume_info").empty();
	var navigatepages=result.extend.resumepageInfos.navigatepageNums;
	//当前页
	var pageNum=result.extend.resumepageInfos.pageNum;
	
	
	var firstPage=$("<li></li>").append($("<a></a>").append("首页"));
	
	firstPage.click(function () {
		MyResumeTopage(1);
	});
	var perviousPage=$("<li></li>").append($("<a></a>").append("&laquo;"));
	
	perviousPage.click(function() {
			if(result.extend.resumepageInfos.hasPreviousPage==true){
			
				MyResumeTopage(result.extend.resumepageInfos.prePage);
			}
		});
		
	var nextPage=$("<li></li>").append($("<a></a>").append("&raquo;"));
	
	nextPage.click(function() {
	if(result.extend.resumepageInfos.hasNextPage==true)
	{
		
		MyResumeTopage(result.extend.resumepageInfos.nextPage);
	}
	});
	var lastPage=$("<li></li>").append($("<a></a>").append("末页"));
	
	lastPage.click(function () {
		MyResumeTopage(result.extend.resumepageInfos.pages);
	});
	
	var ul=$("<ul></ul>").addClass("pagination");
	var nav=$("<nav></nav>");
	//判断是否有前一页
	if(result.extend.resumepageInfos.hasPreviousPage==false)
		{
		firstPage.addClass("disabled");
		perviousPage.addClass("disabled ");
		}
	ul.append(firstPage).append(perviousPage);
	//遍历插入并添加点击事件
	$.each(navigatepages,function(index,items){
		var numli= $("<li></li>").append($("<a></a>").append(items));
		if(pageNum==items){
		
			numli.addClass("active");
		}
		numli.click(function() {
			MyResumeTopage(items);
		});
		ul.append(numli);
		});
	
	//判断是否有后一页
	if(result.extend.resumepageInfos.hasNextPage==false)
	{
	nextPage.addClass("disabled");
	lastPage.addClass("disabled");
	}
	ul.append(nextPage).append(lastPage);
	nav.append(ul).appendTo("#resume_info");
}
//显示单个简历详细信息
function MyResumeDetialInfo(result){
	$("#oneresume").empty();
	$("#myResumeModal").modal({
		backdrop:"static"
	});
	
	var OneRec=result.extend.selectOneResumeWithByUid;
	
	//招聘者
	var baseinfo=$("<span></span>").append("基本信息").addClass("label label-info");
	var baseinfo1=$("<dt></dt>").append(baseinfo);
	var baseinfo2=$("<dt></dt>")
	.append("姓名： ").append(OneRec.name)
	.append("  ,  ")
	.append("年龄：").append(OneRec.age)
	.append("  ,  ");
	var baseinfo3=$("<dt></dt>")
	.append("邮箱：").append(OneRec.email)
	.append("电话：").append(OneRec.phone);
	//
	var educationinfo=$("<span></span>").append("教育背景").addClass("label label-info");
	var baseinfo4=$("<dt></dt>").append(educationinfo);

	var baseinfo5=$("<dt></dt>")
	.append("院校： ").append(OneRec.college)
	.append("  ,  ")
	.append("专业：").append(OneRec.major);
	//
	var applyinfo=$("<span></span>").append("求职意向").addClass("label label-info");
	var baseinfo6=$("<dt></dt>").append(applyinfo);

	var baseinfo7=$("<dt></dt>")
	.append("意向行业： ").append(OneRec.zhiwei)
	.append("  ,  ")
	.append("意向薪资：").append(OneRec.intendedsalary)
	.append("  ,  ")
	.append("工作经历：").append(OneRec.workexperience)
	.append("  ,  ")
	.append("专业技能：").append(OneRec.skills);
	$("<dl></dl>")
	.append(baseinfo1)
	.append(baseinfo2)
	.append(baseinfo3)
	.append(baseinfo4)
	.append(baseinfo5)
	.append(baseinfo6)
	.append(baseinfo7)
	.appendTo("#oneresume");
}


</script>
</body>
</html>